package com.songlanyun.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

public class WithdrawConstant {


    /**
     * 提现类型
     * 0商家所得提现
     * 1会员分佣金提现
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum WithdrawType implements IntegerEnum<Integer> {

        SHOP_WITHDRAW(0, "商家所得提现"),

        MEMBER_WITHDRAW(1, "会员分佣金提现"),

        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        WithdrawType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static WithdrawConstant.WithdrawType getByCode(int code) {
            for (WithdrawConstant.WithdrawType value : WithdrawConstant.WithdrawType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 收款方式：
     * 0微信，
     * 1支付宝，
     * 2银行线下
     * 3现金支付
     * 4公益积分
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum PaymentTerm implements IntegerEnum<Integer> {

        WE_CHAT(0, "微信"),
        ALIPAY(1, "支付宝"),
        BANK(2, "银行线下"),
        READY_UP(3, "现金支付"),
        WELFARE_INTEGRAL(4, "公益积分"),
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        PaymentTerm(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static WithdrawConstant.PaymentTerm getByCode(int code) {
            for (WithdrawConstant.PaymentTerm value : WithdrawConstant.PaymentTerm.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }

        public static String getMsgByCode(int code) {
            for (WithdrawConstant.PaymentTerm value : WithdrawConstant.PaymentTerm.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value.msg;
                }
            }
            return null;
        }
    }

    /**
     * 审核状态
     * 0待审核
     * 1审核通过
     * 2审核不通过
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum VerifyStatus implements IntegerEnum<Integer> {

        VERIFY_WAIT(0, "待审核"),
        VERIFY_PASS(1, "审核通过"),
        VERIFY_NO_PASS(2, "审核不通过"),
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        VerifyStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static WithdrawConstant.VerifyStatus getByCode(int code) {
            for (WithdrawConstant.VerifyStatus value : WithdrawConstant.VerifyStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 用户类型
     * 0：会员
     * 1：商家
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum UserType implements IntegerEnum<Integer> {

        MEMBER(0, "会员"),
        SHOP(1, "商家"),
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        UserType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static WithdrawConstant.UserType getByCode(int code) {
            for (WithdrawConstant.UserType value : WithdrawConstant.UserType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 提现方式
     * 11: 提现到支付宝
     * 21: 提现到微信
     * 31：提现到银行
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum WithdrawThirdType implements IntegerEnum<Integer> {

        WITHDRAW_TO_PAY_ALIPAY(11, "提现到支付宝"),
        WITHDRAW_MONEY_TO_WECHAT(21, "提现到微信"),
        WITHDRAW_MONEY_TO_BANK(31, "提现到银行"),
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        WithdrawThirdType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static WithdrawConstant.WithdrawThirdType getByCode(int code) {
            for (WithdrawConstant.WithdrawThirdType value : WithdrawConstant.WithdrawThirdType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }
}
